Language Changes  >  Types  >  Namespaces

Type Classification in the CLR

The CLR groups types into two different categories: reference types, and value types. Reference types are allocated off of the managed heap. They include all object references, interfaces, and managed pointer types. Reference types have alias semantics, meaning that copying the reference results in an alias. A change to the alias is also reflected in the original reference.

 

In contrast, value types have value semantics for assignment and copying. Assigning or copying a value type results in two distinct entities, and a change in one does not affect the other. Value types include scalar values, and enumerations. Value types incur a much smaller performance and resource penalty, as they are allocated on the thread's stack (as opposed to the managed heap). In Delphi for Microsoftâ .NET, records are value types.

 

Delphi for .NET supports packed records, however the semantics of this keyword are changed slightly. In Delphi for .NET, the packed keyword means the JIT compiler cannot move, reorder, or add padding between fields of a record. The packed keyword effectively disables the JIT compiler's ability to optimize the layout of a record type. The ability to disable such optimization can be important when creating value types that will be used to interoperate with unmanaged code.

 

Primitive Type Mapping

 

Delphi Type

.NET Framework Type

ShortInt

System.SByte

Byte

System.Byte

SmallInt

System.Int16

Word

System.UInt16

Integer

System.Int32

Cardinal/LongWord

System.UInt32

Int64

System.Int64

UInt64

System.UInt64

Char/WideChar

System.Char

Single

System.Single

Double/Extended

System.Double

Boolean

System.Boolean

WideString/string

System.String

 

Notes:

 


Top  |  Contents  |  Copyrights  |  Borland Developer Network  |  Borland Home